var read_line = require('readline-sync')
read_line.setDefaultOptions({ prompt: '' })
var read_line = read_line.prompt
// let arr = read_line().split(' ') // 得到字符串数组
let arr = ['nihao']
var longestCommonPrefix = function (strs) {
  var re = '';
  if (!strs.length) return re;
  for (var j = 0; j < strs[0].length; j++) {//第j位
    for (var i = 1; i < strs.length; i++) {//第i个
      if (strs[i][j] != strs[0][j]) return re
    }
    re += strs[0][j];
  }
  return re;
};
console.log(longestCommonPrefix(arr));